package com.guqinghan.guqinghan_03_sqllite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class MyOpenSqlLite extends SQLiteOpenHelper {

    public static final int VERSION = 2;
    private MyOpenSqlLite myOpenSqlLite;
    private static  final  String SQLITEDATABASENAME = "guqinghan.db";
    private MyOpenSqlLite(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, null, VERSION);
    }

    public static MyOpenSqlLite getInstance(Context context){
        return new MyOpenSqlLite(context, SQLITEDATABASENAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        Log.i("sqlliteinfo", "onCreate");
        sqLiteDatabase.execSQL("create table user(_id integer primary key autoincrement,name varchar)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        Log.i("sqlliteinfo", "onUpgrade");
        sqLiteDatabase.execSQL("create table notpad(_id integer primary key autoincrement,money varchar)");
    }
}
